import { ref } from 'vue';

import { getRoomTypeInfoList } from '#/api';

interface RoomType {
  bedNum: number | string;
  bedType: string;
  bedWidth: string;
  floor: string;
  id: number;
  images: string;
  imagesNum: number;
  maxAdult: number;
  maxChild: number;
  maxGuests: number;
  nameZh: string;
  roomArea: number;
  roomNum: number;
  sellPrice: number;
}

export function useRoomList() {
  const roomList = ref<RoomType[]>([]);

  const fetchRoomList = async (params?: any) => {
    try {
      const { data } = await getRoomTypeInfoList(params);
      roomList.value = data;
    } catch (error_) {
      console.error('获取房型列表失败:', error_);
    }
  };

  return {
    roomList,
    fetchRoomList,
  };
}
